input=$1
if [ $# -eq 0 ]
  then
    echo "No arguments supplied"
    echo "Please provide path of host port list"
    exit 1
fi
while IFS= read -r line
do
  echo "$line"
  host=$(echo $line | cut -f1 -d " ")
  port=$(echo $line | cut -f2 -d " ")
  echo "" > /dev/tcp/$host/$port && echo "${host}:${port} is open" | \
  tee -a ./open.output
done < "$input" 2>>closed.output